<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>表单数据</title>
	</head>
	<body>
		<div id="app">
			请输入数值:<input type="text" v-model.number="num" />
			<br />
			<button @click="addNum">计算</button>
			<br />
			<!-- 去除空格 -->
			用户名:<input type="text" v-model.trim="username" />
			<button @click="nameSize">长度</button>
			{{length}}
			
			<br />
			<!-- 懒加载 当用户输入完成之后,失去焦点时才会触发-->
			<input type="text" v-model.lazy="msg"/>{{msg}}
		</div>
		<script src="../js/vue.js"></script>
		<script>
			const app=new Vue({
				el:"#app",
				data:{
					num: '',
					username: '',
					length:'',
					msg:''
				},
				methods:{
					addNum(){
						/* console.log(parseInt(this.num)+12) */
						this.num=this.num+12
					},
					nameSize(){
						this.length=this.username.length
					}
				}
			})
		</script>
	</body>
</html>
